@echo off
setlocal

:: 设置 Redis 主节点和从节点的目录
set MASTER_DIR=master
set SLAVE1_DIR=slave1
set SLAVE2_DIR=slave2
set CLI_DIR=master

:: 用户输入
set /p OPTION="Enter the type to start (master, slave1, slave2, cli): "

:: 根据用户输入启动对应的 Redis 实例或客户端
if "%OPTION%"=="master" (
    echo Starting Redis Master Node...
    start "" "%MASTER_DIR%\redis-server.exe" "%MASTER_DIR%\redis.windows.conf"
    echo Starting Redis CLI for Master Node...
    start "" "%CLI_DIR%\redis-cli.exe" -p 6379
) else if "%OPTION%"=="slave1" (
    echo Starting Redis Slave Node 1...
    start "" "%SLAVE1_DIR%\redis-server.exe" "%SLAVE1_DIR%\redis.windows.conf"
    echo Starting Redis CLI for Slave Node 1...
    start "" "%CLI_DIR%\redis-cli.exe" -p 6380
) else if "%OPTION%"=="slave2" (
    echo Starting Redis Slave Node 2...
    start "" "%SLAVE2_DIR%\redis-server.exe" "%SLAVE2_DIR%\redis.windows.conf"
    echo Starting Redis CLI for Slave Node 2...
    start "" "%CLI_DIR%\redis-cli.exe" -p 6381
) else if "%OPTION%"=="cli" (
    echo Starting Redis CLI...
    echo Please enter the port (6379 for master, 6380 for slave1, 6381 for slave2):
    set /p CLI_PORT="Port: "
    start "" "%CLI_DIR%\redis-cli.exe" -p %CLI_PORT%
) else (
    echo Invalid option. Please enter master, slave1, slave2, or cli.
)

endlocal
pause
